0 CpxTRS
↳1 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳2 CpxWeightedTrs
↳3 TypeInferenceProof (BOTH BOUNDS(ID, ID), 0 ms)
↳4 CpxTypedWeightedTrs
↳5 CompletionProof (UPPER BOUND(ID), 0 ms)
↳6 CpxTypedWeightedCompleteTrs
↳7 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 0 ms)
↳8 CpxRNTS
↳9 CompleteCoflocoProof (⇔, 876 ms)
↳10 BOUNDS(1, n^2)
cond(true, x, y, z) → cond(and(gr(x, z), gr(y, z)), p(x), p(y), z)
and(true, true) → true
and(x, false) → false
and(false, x) → false
gr(0, 0) → false
gr(0, x) → false
gr(s(x), 0) → true
gr(s(x), s(y)) → gr(x, y)
p(0) → 0
p(s(x)) → x
cond(true, x, y, z) → cond(and(gr(x, z), gr(y, z)), p(x), p(y), z) [1]
and(true, true) → true [1]
and(x, false) → false [1]
and(false, x) → false [1]
gr(0, 0) → false [1]
gr(0, x) → false [1]
gr(s(x), 0) → true [1]
gr(s(x), s(y)) → gr(x, y) [1]
p(0) → 0 [1]
p(s(x)) → x [1]
cond(true, x, y, z) → cond(and(gr(x, z), gr(y, z)), p(x), p(y), z) [1]
and(true, true) → true [1]
and(x, false) → false [1]
and(false, x) → false [1]
gr(0, 0) → false [1]
gr(0, x) → false [1]
gr(s(x), 0) → true [1]
gr(s(x), s(y)) → gr(x, y) [1]
p(0) → 0 [1]
p(s(x)) → x [1]
cond :: true:false → 0:s → 0:s → 0:s → cond true :: true:false and :: true:false → true:false → true:false gr :: 0:s → 0:s → true:false p :: 0:s → 0:s false :: true:false 0 :: 0:s s :: 0:s → 0:s |
cond(v0, v1, v2, v3) → null_cond [0]
null_cond
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
true => 1
false => 0
0 => 0
null_cond => 0
and(z', z'') -{ 1 }→ 1 :|: z' = 1, z'' = 1
and(z', z'') -{ 1 }→ 0 :|: z'' = 0, z' = x, x >= 0
and(z', z'') -{ 1 }→ 0 :|: x >= 0, z'' = x, z' = 0
cond(z', z'', z1, z2) -{ 1 }→ cond(and(gr(x, z), gr(y, z)), p(x), p(y), z) :|: z1 = y, z >= 0, z2 = z, x >= 0, y >= 0, z'' = x, z' = 1
cond(z', z'', z1, z2) -{ 0 }→ 0 :|: z2 = v3, v0 >= 0, z1 = v2, v1 >= 0, z'' = v1, v2 >= 0, v3 >= 0, z' = v0
gr(z', z'') -{ 1 }→ gr(x, y) :|: z' = 1 + x, x >= 0, y >= 0, z'' = 1 + y
gr(z', z'') -{ 1 }→ 1 :|: z'' = 0, z' = 1 + x, x >= 0
gr(z', z'') -{ 1 }→ 0 :|: z'' = 0, z' = 0
gr(z', z'') -{ 1 }→ 0 :|: x >= 0, z'' = x, z' = 0
p(z') -{ 1 }→ x :|: z' = 1 + x, x >= 0
p(z') -{ 1 }→ 0 :|: z' = 0
eq(start(V, V1, V2, V3),0,[cond(V, V1, V2, V3, Out)],[V >= 0,V1 >= 0,V2 >= 0,V3 >= 0]). eq(start(V, V1, V2, V3),0,[and(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V2, V3),0,[gr(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V2, V3),0,[p(V, Out)],[V >= 0]). eq(cond(V, V1, V2, V3, Out),1,[gr(V4, V5, Ret00),gr(V6, V5, Ret01),and(Ret00, Ret01, Ret0),p(V4, Ret1),p(V6, Ret2),cond(Ret0, Ret1, Ret2, V5, Ret)],[Out = Ret,V2 = V6,V5 >= 0,V3 = V5,V4 >= 0,V6 >= 0,V1 = V4,V = 1]). eq(and(V, V1, Out),1,[],[Out = 1,V = 1,V1 = 1]). eq(and(V, V1, Out),1,[],[Out = 0,V1 = 0,V = V7,V7 >= 0]). eq(and(V, V1, Out),1,[],[Out = 0,V8 >= 0,V1 = V8,V = 0]). eq(gr(V, V1, Out),1,[],[Out = 0,V1 = 0,V = 0]). eq(gr(V, V1, Out),1,[],[Out = 0,V9 >= 0,V1 = V9,V = 0]). eq(gr(V, V1, Out),1,[],[Out = 1,V1 = 0,V = 1 + V10,V10 >= 0]). eq(gr(V, V1, Out),1,[gr(V11, V12, Ret3)],[Out = Ret3,V = 1 + V11,V11 >= 0,V12 >= 0,V1 = 1 + V12]). eq(p(V, Out),1,[],[Out = 0,V = 0]). eq(p(V, Out),1,[],[Out = V13,V = 1 + V13,V13 >= 0]). eq(cond(V, V1, V2, V3, Out),0,[],[Out = 0,V3 = V14,V15 >= 0,V2 = V16,V17 >= 0,V1 = V17,V16 >= 0,V14 >= 0,V = V15]). input_output_vars(cond(V,V1,V2,V3,Out),[V,V1,V2,V3],[Out]). input_output_vars(and(V,V1,Out),[V,V1],[Out]). input_output_vars(gr(V,V1,Out),[V,V1],[Out]). input_output_vars(p(V,Out),[V],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. non_recursive : [and/3]
1. recursive : [gr/3]
2. non_recursive : [p/2]
3. recursive : [cond/5]
4. non_recursive : [start/4]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into and/3
1. SCC is partially evaluated into gr/3
2. SCC is partially evaluated into p/2
3. SCC is partially evaluated into cond/5
4. SCC is partially evaluated into start/4
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations and/3
* CE 9 is refined into CE [16]
* CE 8 is refined into CE [17]
* CE 10 is refined into CE [18]
### Cost equations --> "Loop" of and/3
* CEs [16] --> Loop 12
* CEs [17] --> Loop 13
* CEs [18] --> Loop 14
### Ranking functions of CR and(V,V1,Out)
#### Partial ranking functions of CR and(V,V1,Out)
### Specialization of cost equations gr/3
* CE 13 is refined into CE [19]
* CE 12 is refined into CE [20]
* CE 11 is refined into CE [21]
### Cost equations --> "Loop" of gr/3
* CEs [20] --> Loop 15
* CEs [21] --> Loop 16
* CEs [19] --> Loop 17
### Ranking functions of CR gr(V,V1,Out)
* RF of phase [17]: [V,V1]
#### Partial ranking functions of CR gr(V,V1,Out)
* Partial RF of phase [17]:
- RF of loop [17:1]:
V
V1
### Specialization of cost equations p/2
* CE 15 is refined into CE [22]
* CE 14 is refined into CE [23]
### Cost equations --> "Loop" of p/2
* CEs [22] --> Loop 18
* CEs [23] --> Loop 19
### Ranking functions of CR p(V,Out)
#### Partial ranking functions of CR p(V,Out)
### Specialization of cost equations cond/5
* CE 7 is refined into CE [24]
* CE 6 is refined into CE [25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40]
### Cost equations --> "Loop" of cond/5
* CEs [40] --> Loop 20
* CEs [37] --> Loop 21
* CEs [35,36] --> Loop 22
* CEs [39] --> Loop 23
* CEs [32] --> Loop 24
* CEs [38] --> Loop 25
* CEs [33,34] --> Loop 26
* CEs [31] --> Loop 27
* CEs [30] --> Loop 28
* CEs [28,29] --> Loop 29
* CEs [27] --> Loop 30
* CEs [25,26] --> Loop 31
* CEs [24] --> Loop 32
### Ranking functions of CR cond(V,V1,V2,V3,Out)
* RF of phase [20]: [V1-1,V1-V3,V2-1,V2-V3]
* RF of phase [24]: [V1,V2]
#### Partial ranking functions of CR cond(V,V1,V2,V3,Out)
* Partial RF of phase [20]:
- RF of loop [20:1]:
V1-1
V1-V3
V2-1
V2-V3
* Partial RF of phase [24]:
- RF of loop [24:1]:
V1
V2
### Specialization of cost equations start/4
* CE 2 is refined into CE [41,42,43,44,45,46,47,48,49,50,51,52,53,54]
* CE 3 is refined into CE [55,56,57]
* CE 4 is refined into CE [58,59,60,61]
* CE 5 is refined into CE [62,63]
### Cost equations --> "Loop" of start/4
* CEs [54] --> Loop 33
* CEs [49,53] --> Loop 34
* CEs [52] --> Loop 35
* CEs [51] --> Loop 36
* CEs [50] --> Loop 37
* CEs [48] --> Loop 38
* CEs [47] --> Loop 39
* CEs [46] --> Loop 40
* CEs [45] --> Loop 41
* CEs [56] --> Loop 42
* CEs [44,60,61,63] --> Loop 43
* CEs [41,43] --> Loop 44
* CEs [42,57,59] --> Loop 45
* CEs [55,58,62] --> Loop 46
### Ranking functions of CR start(V,V1,V2,V3)
#### Partial ranking functions of CR start(V,V1,V2,V3)
Computing Bounds
=====================================
#### Cost of chains of and(V,V1,Out):
* Chain [14]: 1
with precondition: [V=0,Out=0,V1>=0]
* Chain [13]: 1
with precondition: [V=1,V1=1,Out=1]
* Chain [12]: 1
with precondition: [V1=0,Out=0,V>=0]
#### Cost of chains of gr(V,V1,Out):
* Chain [[17],16]: 1*it(17)+1
Such that:it(17) =< V
with precondition: [Out=0,V>=1,V1>=V]
* Chain [[17],15]: 1*it(17)+1
Such that:it(17) =< V1
with precondition: [Out=1,V1>=1,V>=V1+1]
* Chain [16]: 1
with precondition: [V=0,Out=0,V1>=0]
* Chain [15]: 1
with precondition: [V1=0,Out=1,V>=1]
#### Cost of chains of p(V,Out):
* Chain [19]: 1
with precondition: [V=0,Out=0]
* Chain [18]: 1
with precondition: [V=Out+1,V>=1]
#### Cost of chains of cond(V,V1,V2,V3,Out):
* Chain [[24],32]: 6*it(24)+0
Such that:it(24) =< V2
with precondition: [V=1,V3=0,Out=0,V1>=1,V2>=1]
* Chain [[24],31,32]: 6*it(24)+6
Such that:it(24) =< V1
with precondition: [V=1,V3=0,Out=0,V1=V2,V1>=1]
* Chain [[24],30,32]: 6*it(24)+6
Such that:it(24) =< V1
with precondition: [V=1,V3=0,Out=0,V1>=1,V2>=V1+1]
* Chain [[24],27,32]: 6*it(24)+6
Such that:it(24) =< V2
with precondition: [V=1,V3=0,Out=0,V2>=1,V1>=V2+1]
* Chain [[20],32]: 6*it(20)+2*s(5)+0
Such that:it(20) =< V1-V3
aux(2) =< V3
s(6) =< it(20)*aux(2)
s(5) =< s(6)
with precondition: [V=1,Out=0,V3>=1,V1>=V3+1,V2>=V3+1]
* Chain [[20],23,32]: 6*it(20)+2*s(5)+2*s(7)+6
Such that:it(20) =< V2-V3
aux(3) =< V3
s(7) =< aux(3)
s(6) =< it(20)*aux(3)
s(5) =< s(6)
with precondition: [V=1,Out=0,V3>=1,V1>=V2+1,V2>=V3+1]
* Chain [[20],22,32]: 6*it(20)+2*s(5)+4*s(9)+6
Such that:it(20) =< V2-V3
aux(6) =< V3
s(9) =< aux(6)
s(6) =< it(20)*aux(6)
s(5) =< s(6)
with precondition: [V=1,Out=0,V2=V1,V3>=1,V2>=V3+1]
* Chain [[20],21,32]: 6*it(20)+2*s(5)+2*s(13)+6
Such that:it(20) =< V1-V3
aux(7) =< V3
s(13) =< aux(7)
s(6) =< it(20)*aux(7)
s(5) =< s(6)
with precondition: [V=1,Out=0,V3>=1,V2>=V1+1,V1>=V3+1]
* Chain [32]: 0
with precondition: [Out=0,V>=0,V1>=0,V2>=0,V3>=0]
* Chain [31,32]: 6
with precondition: [V=1,V1=0,V2=0,Out=0,V3>=0]
* Chain [30,32]: 6
with precondition: [V=1,V1=0,V3=0,Out=0,V2>=1]
* Chain [29,32]: 2*s(15)+6
Such that:aux(8) =< V2
s(15) =< aux(8)
with precondition: [V=1,V1=0,Out=0,V2>=1,V3>=V2]
* Chain [28,32]: 1*s(17)+6
Such that:s(17) =< V3
with precondition: [V=1,V1=0,Out=0,V3>=1,V2>=V3+1]
* Chain [27,32]: 6
with precondition: [V=1,V2=0,V3=0,Out=0,V1>=1]
* Chain [26,32]: 2*s(18)+6
Such that:aux(9) =< V1
s(18) =< aux(9)
with precondition: [V=1,V2=0,Out=0,V1>=1,V3>=V1]
* Chain [25,32]: 1*s(20)+6
Such that:s(20) =< V3
with precondition: [V=1,V2=0,Out=0,V3>=1,V1>=V3+1]
* Chain [23,32]: 1*s(7)+1*s(8)+6
Such that:s(8) =< V2
s(7) =< V3
with precondition: [V=1,Out=0,V2>=1,V3>=V2,V1>=V3+1]
* Chain [22,32]: 2*s(9)+2*s(10)+6
Such that:aux(4) =< V1
aux(5) =< V2
s(9) =< aux(4)
s(10) =< aux(5)
with precondition: [V=1,Out=0,V1>=1,V2>=1,V3>=V1,V3>=V2]
* Chain [21,32]: 1*s(13)+1*s(14)+6
Such that:s(13) =< V1
s(14) =< V3
with precondition: [V=1,Out=0,V1>=1,V3>=V1,V2>=V3+1]
#### Cost of chains of start(V,V1,V2,V3):
* Chain [46]: 1
with precondition: [V=0]
* Chain [45]: 6
with precondition: [V1=0,V>=0]
* Chain [44]: 2*s(35)+6
Such that:s(34) =< V2
s(35) =< s(34)
with precondition: [V>=0,V1>=0,V2>=0,V3>=0]
* Chain [43]: 1*s(36)+1*s(37)+1*s(38)+6
Such that:s(37) =< V
s(38) =< V1
s(36) =< V3
with precondition: [V>=1]
* Chain [42]: 1
with precondition: [V=1,V1=1]
* Chain [41]: 6
with precondition: [V=1,V2=0,V3=0,V1>=1]
* Chain [40]: 2*s(40)+6
Such that:s(39) =< V1
s(40) =< s(39)
with precondition: [V=1,V2=0,V1>=1,V3>=V1]
* Chain [39]: 1*s(41)+6
Such that:s(41) =< V3
with precondition: [V=1,V2=0,V3>=1,V1>=V3+1]
* Chain [38]: 12*s(44)+12*s(45)+6
Such that:s(42) =< V1
s(43) =< V2
s(44) =< s(42)
s(45) =< s(43)
with precondition: [V=1,V3=0,V1>=1,V2>=1]
* Chain [37]: 2*s(48)+2*s(49)+6
Such that:s(46) =< V1
s(47) =< V2
s(48) =< s(46)
s(49) =< s(47)
with precondition: [V=1,V1>=1,V2>=1,V3>=V1,V3>=V2]
* Chain [36]: 1*s(50)+1*s(51)+6
Such that:s(50) =< V1
s(51) =< V3
with precondition: [V=1,V1>=1,V3>=V1,V2>=V3+1]
* Chain [35]: 1*s(52)+1*s(53)+6
Such that:s(52) =< V2
s(53) =< V3
with precondition: [V=1,V2>=1,V3>=V2,V1>=V3+1]
* Chain [34]: 12*s(54)+6*s(55)+4*s(58)+6*s(59)+2*s(61)+6
Such that:s(55) =< V2-V3
aux(13) =< V1-V3
aux(14) =< V3
s(54) =< aux(13)
s(57) =< s(54)*aux(14)
s(58) =< s(57)
s(59) =< aux(14)
s(60) =< s(55)*aux(14)
s(61) =< s(60)
with precondition: [V=1,V3>=1,V1>=V3+1,V2>=V3+1]
* Chain [33]: 6*s(67)+2*s(69)+2*s(71)+6
Such that:s(67) =< V2-V3
s(68) =< V3
s(69) =< s(68)
s(70) =< s(67)*s(68)
s(71) =< s(70)
with precondition: [V=1,V3>=1,V1>=V2+1,V2>=V3+1]
Closed-form bounds of start(V,V1,V2,V3):
-------------------------------------
* Chain [46] with precondition: [V=0]
- Upper bound: 1
- Complexity: constant
* Chain [45] with precondition: [V1=0,V>=0]
- Upper bound: 6
- Complexity: constant
* Chain [44] with precondition: [V>=0,V1>=0,V2>=0,V3>=0]
- Upper bound: 2*V2+6
- Complexity: n
* Chain [43] with precondition: [V>=1]
- Upper bound: V+6+nat(V1)+nat(V3)
- Complexity: n
* Chain [42] with precondition: [V=1,V1=1]
- Upper bound: 1
- Complexity: constant
* Chain [41] with precondition: [V=1,V2=0,V3=0,V1>=1]
- Upper bound: 6
- Complexity: constant
* Chain [40] with precondition: [V=1,V2=0,V1>=1,V3>=V1]
- Upper bound: 2*V1+6
- Complexity: n
* Chain [39] with precondition: [V=1,V2=0,V3>=1,V1>=V3+1]
- Upper bound: V3+6
- Complexity: n
* Chain [38] with precondition: [V=1,V3=0,V1>=1,V2>=1]
- Upper bound: 12*V1+12*V2+6
- Complexity: n
* Chain [37] with precondition: [V=1,V1>=1,V2>=1,V3>=V1,V3>=V2]
- Upper bound: 2*V1+2*V2+6
- Complexity: n
* Chain [36] with precondition: [V=1,V1>=1,V3>=V1,V2>=V3+1]
- Upper bound: V1+V3+6
- Complexity: n
* Chain [35] with precondition: [V=1,V2>=1,V3>=V2,V1>=V3+1]
- Upper bound: V2+V3+6
- Complexity: n
* Chain [34] with precondition: [V=1,V3>=1,V1>=V3+1,V2>=V3+1]
- Upper bound: 6*V2-6*V3+ (12*V1-12*V3+ (6*V3+6+ (V1-V3)* (4*V3)+ (V2-V3)* (2*V3)))
- Complexity: n^2
* Chain [33] with precondition: [V=1,V3>=1,V1>=V2+1,V2>=V3+1]
- Upper bound: 6*V2-6*V3+ (2*V3+6+ (V2-V3)* (2*V3))
- Complexity: n^2
### Maximum cost of start(V,V1,V2,V3): max([max([max([5,nat(V2)*2+5]),nat(V2)*10+nat(V1)*10+nat(V2)*2+ (nat(V1)*2+5)]),nat(V3)+5+max([max([nat(V2),nat(V3)*4*nat(V1-V3)+nat(V3)*4+nat(V1-V3)*12+ (nat(V3)*2*nat(V2-V3)+nat(V3)+nat(V2-V3)*6)]),nat(V1)+V])])+1
Asymptotic class: n^2
* Total analysis performed in 757 ms.